﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DataAccess_Layer
{
    public static class Aspnet_MembershipDAC
    {
        public static object getQLUser()
        {
            Guid adminID = RoleDAC.getAdminRoleID();
            return DataAccessHelper.DB.aspnet_Memberships.Where(mbs => adminID != DataAccessHelper.DB.aspnet_UsersInRoles.Where(uir => uir.UserId == mbs.UserId).Select(uir => uir.RoleId).First()).Select(mbs => new { UserName = mbs.aspnet_User.UserName, Banned = mbs.IsLockedOut, RoleName = DataAccessHelper.DB.aspnet_UsersInRoles.Where(uir => uir.UserId == mbs.UserId).Select(uir => uir.aspnet_Role.RoleName).First(), RoleID = DataAccessHelper.DB.aspnet_UsersInRoles.Where(uir => uir.UserId == mbs.UserId).Select(uir => uir.RoleId).First(), mbs.Email, mbs.LastLoginDate, mbs.CreateDate });
        }

        public static void setIsLockedOut(string userName, bool isLockedOut)
        {
            aspnet_Membership user = DataAccessHelper.DB.aspnet_Memberships.Where(us => us.aspnet_User.UserName == userName).Select(us => us).First();
            user.IsLockedOut = isLockedOut;            
            DataAccessHelper.Save();
        }
    }
}
